package com.ly.common.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;

/**
 * 菜单首页-枚举
 *
 * @author luoyun
 * @Date: 2025/5/14 15:22
 * @Note:
 */
@Getter
@AllArgsConstructor
public enum MenuIndexEnum {
    ADMIN("admin", "/dashboard/analysis"),
    TEST("test", "/dashboard/IndexChart"),
    HR("hr", "/dashboard/IndexBdc"),
    DM("dm", "/dashboard/IndexTask"),
    ROLE_INDEX_CONFIG_ENUM("RoleIndexConfigEnumDefault", "/dashboard/analysis"),
    /**
     * 全局的
     */
    GLOBAL("global", "/dashboard/analysis"),
    ;

    /**
     * 用户角色
     */
    String code;
    /**
     * 首页url
     */
    String url;

    /**
     * 根据用户角色查询对应的首页
     *
     * @param roles
     * @return
     */
    public static String getMenuIndexByRoles(List<String> roles) {
        MenuIndexEnum[] values = values();
        for (MenuIndexEnum value : values) {
            if (roles.contains(value.getCode())) {
                return value.getUrl();
            }
        }
        return MenuIndexEnum.GLOBAL.getUrl();
    }
}
